package com.liner.collection;

import java.util.ArrayList;
import java.util.Collection;

public class GenericDemo {
    public static void main(String[] args) {
        Collection<Point> points = new ArrayList<>();
        points.add(new Point(1,2));
        points.add(new Point(3,5));
        points.add(new Point(6,1));
        points.add(new Point(5,7));
        points.add(new Point(7,2));

        for (Point point : points) {
            System.out.println(point);
        }


        Collection<String> c = new ArrayList<>();
        c.add("hello1");
        c.add("hello2");
        c.add("hello3");
        c.add("hello4");

        //迭代器所指定的泛型应当与遍历的集合的泛型一致
        for (String s : c) {
            System.out.println(s);
        }
    }
}
